<!--
 * @Author: WuFeng <763467339@qq.com>
 * @Date: 2022-03-22 12:12:49
 * @LastEditTime: 2022-07-08 18:54:40
 * @LastEditors: WuFeng <763467339@qq.com>
 * @Description:
 * @FilePath: \vue3-element-plus-web\src\views\Layouts\Admin\components\Sidebar\index.vue
 * Copyright 版权声明
-->
<template>
  <el-scrollbar wrapClass="scrollbar-wrapper">
    <div class="pro-log">
      <img src="../../../../../assets/images/login/logo-1.png" alt="">
      <!-- <span>{{ $t('layout.systemName') }}</span> -->
    </div>
    <div class="pro-log small">
      <img src="../../../../../assets/images/login/logo-small.png" alt="">
      <!-- <span>{{ $t('layout.systemName') }}</span> -->
    </div>
    <el-menu
      mode="vertical"
      :show-timeout="200"
      :default-active="$route.path"
      :collapse="isCollapse"
      background-color="transparent"
      text-color="#fff"
      active-text-color="#fff"
    >
      <template v-if="sidebarTopActive === '1'">
        <!-- vue router访问 -->
        <div class="mysys-sidebar">
          <!-- <sidebar-item v-for="route in permissionRouters" :key="route.name" :item="route" :base-path="route.path"></sidebar-item> -->
          <template v-for="route in permissionRouters">
            <template v-if="route.iframeRender === true">
              <sidebar-item-link-one
                :key="route.name"
                :item="route"
                :base-path="route.path"
                :baseUrl="authUrl"
              >
              </sidebar-item-link-one>
            </template>
            <template v-else>
              <sidebar-item
                :key="route.name"
                :item="route"
                :base-path="route.path">
              </sidebar-item>
            </template>
          </template>
        </div>
      </template>
      <template v-else>
        <!-- iframe访问--权限系统菜单 -->
        <template v-if="sidebarTopActive === '2'">
          <div class="authsys-sidebar">
            <sidebar-item-link
              v-for="routeAuth in permissionAuthRouters"
              :key="'auth_' + routeAuth.name"
              :item="routeAuth"
              :base-path="routeAuth.path"
              :baseUrl="authUrl"
            >
            </sidebar-item-link>
          </div>
        </template>
      </template>
    </el-menu>
  </el-scrollbar>
</template>

<script>
import { mapGetters } from 'vuex'
import SidebarItem from './SidebarItem'
import SidebarItemLink from './SidebarItemLink'
import SidebarItemLinkOne from './SidebarItemLinkOne'

export default {
  components: {
    SidebarItem,
    SidebarItemLink,
    SidebarItemLinkOne
  },
  computed: {
    ...mapGetters([
      'sidebar',
      'sidebarTopActive',
      'permissionRouters',
      'permissionAuthRouters'
    ]),
    routes() {
      return this.$router.options.routes
    },
    isCollapse() {
      return !this.sidebar.opened
    }
  },
  data() {
    return {
      authUrl: process.env.AUTH_URL
    }
  },
  created() {
    // console.log(this.$router.options.routes)
    // console.log(this.sidebarTopActive)
  }
}
</script>
<style lang="scss">
</style>
